<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="视频标题" style="width: 500px">
        <el-input v-model="form.videoName"></el-input>
      </el-form-item>
      <el-form-item label="配文" style="width: 500px">
        <el-input type="textarea" v-model="form.videoCaption"></el-input>
      </el-form-item>
      <el-form-item label="上传视频" >
        <video autoplay controls style=" width: 500px; height:500px"
               v-if="legalPersonVideoImageFile">
          <!-- 这里添加视频源 -->
          <source :src="legalPersonVideoImageFile" type="video/mp4">
          您的浏览器不支持HTML5视频播放功能。
        </video>
        <el-upload
          action="/dev-api/patients/content/upLoad"
          :on-success="onSuccess">
          <i class="el-icon-plus"></i>
        </el-upload>
      </el-form-item>
    </el-form>
    <el-button type="primary" round @click="fa">发 布</el-button>
  </div>
</template>

<script>
  //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  //例如:import <组件名称> from '<组件路径>'================================================================================

  //主
  import {getInfo} from "@/api/login";
  import {healthVideoAdd} from "@/api/system/patients";

  export default {

    //import引入的组件需要注入到对象中才能使用=================================================================================
    components: {},
    props: {},
    data() {
      //这里存放数据======================================================================================================
      return {
        form:{},
        user:{},
        legalPersonVideoImageFile:''
      };
    },
    //计算属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合===========================================================================================================
    methods: {
      fa(){
        this.form.userId = this.user.userId
        this.form.username = this.user.nickName
        this.form.avatar = this.user.avatar
        healthVideoAdd(this.form).then(res => {
          if (res.code === 200){
            this.$message.success('发布成功')
            this.form = {}
            this.legalPersonVideoImageFile = ''
          }
        })
      },
      userList(){
        getInfo().then(res => {
          this.user = res.data.user
        })
      },
      onSuccess(res) {
        this.form.videoAddress = res.data
        this.legalPersonVideoImageFile = res.data
      },
    },
    //生命周期 - 创建完成(可以访问当前this实例)
    created() {
      this.userList()
    },
    //生命周期 - 挂载完成(可以访问DOM元素)
    mounted() {
    },
    beforeCreate() {
    }, //生命周期 - 创建之前
    beforeMount() {
    }, //生命周期 - 挂载之前
    beforeUpdate() {
    }, //生命周期 - 更新之前
    updated() {
    }, //生命周期 - 更新之后
    beforeDestroy() {
    }, //生命周期 - 销毁之前
    destroyed() {
    }, //生命周期 - 销毁完成
    activated() {
    } //如果页面有keep-alive缓存功能,这个函数会触发
  };
</script>
<style scoped>

</style>

